﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;
using NLog.Extensions.Logging;
using Microsoft.Extensions.Logging;

public static class LogHelperExt
{
    public static IServiceCollection InjectLogging(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddLogging((builder) =>
        {
            builder
            .AddConfiguration(configuration?.GetSection("Logging"))
            .SetMinimumLevel(LogLevel.Trace)
            .AddConsole()
            .AddDebug();
        });
        return services;
    }

    public static IServiceCollection InjectNlog(this IServiceCollection services, string configName = "NLog.config")
    {
        services.AddLogging((builder) =>
        {
            builder
            .ClearProviders()
            .SetMinimumLevel(LogLevel.Trace)
            .AddNLog();
            NLog.LogManager.LoadConfiguration(configName);
        });
        return services;
    }
}
